﻿using UnityEngine;
using System.Collections;

public class MainMenu : MonoBehaviour 
{
	public float m_ButtonPositionX = 0.5f;
	public float m_ButtonPositionY = 0.5f;
	
	public float m_ButtonWidth = 0.15f;
	public float m_ButtonHeight = 0.1f;

	public float m_DistanceOffsetX = 5f;
	public float m_DistanceOffsetY = 5f;
	
	private Rect m_ButtonRect = new Rect();
	private Vector2 m_RectPosition = new Vector2();

	void Start () 
	{
		
	}

	void Update () 
	{
	
	}

	private void OnGUI()
	{
		if(GamesManager.Instance)
		{
			for(int i = 0; i < GamesManager.Instance.m_ScenesToLoad.Length; i++)
			{
				m_ButtonRect.width = Screen.width * m_ButtonWidth;
				m_ButtonRect.height = Screen.height * m_ButtonHeight;

				m_RectPosition.x = Screen.width * (m_ButtonPositionX - m_ButtonWidth/2f + (i * (m_ButtonWidth + m_DistanceOffsetX)));
				m_RectPosition.y = Screen.height * (m_ButtonPositionY - m_ButtonHeight/2f);
				m_ButtonRect.position = m_RectPosition;

				if (GUI.Button(m_ButtonRect, GamesManager.Instance.m_ScenesToLoad[i].m_SceneName ))
				{
					Application.LoadLevel((int)GamesManager.Instance.m_ScenesToLoad[i].m_SceneId);
				}
			}
		}
	}
}
